<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择项目收票明细信息</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">收票主题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">收票登记单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">受票单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="shouer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="gonger" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发票类型：</label>
                        <div class="layui-input-block">
                            <select id="piaotype" name="piaotype" lay-filter="piaotype">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">费用类别：</label>
                        <div class="layui-input-block">
                            <select id="yongtype" name="yongtype" lay-filter="yongtype">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" name="flowuser" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_domkey = getQueryVariable('domkey');
    var parent_page = getQueryVariable('page');
    var parent_enginid = getQueryVariable('enginid') || 0;
    var parent_isdi = getQueryVariable('isdi') || '';
    var parent_piaotype = getQueryVariable('piaotype') || 0;


    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_opt_get_piao_shou_list),where: {enginid:parent_enginid,isdi:parent_isdi,piaotype:parent_piaotype}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: ['', '', ''],filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function(res){
                xiala_zhan_one_zuo('piaotype', res.data.piaotype, res.data.is_piaotype);
                xiala_zhan_one_zuo('yongtype', res.data.yongtype, res.data.yongtype);
                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            ,cols: [[
                {type:choose_type}
                ,{field:'sericnum',title:'流程单号',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../piao_shou/show.php?id='+d.id+'\');">'+d.sericnum+'</span>';
                    }}
                ,{field: 'dikouid_name', title: '是否退税'}
                ,{field:'name',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.enginid+'\')">'+d.enginname+'</span>';
                    }}
                ,{field: 'number', title: '收票登记单号'}
                ,{field: 'shouer', title: '受票单位'}
                ,{field: 'gonger', title: '开票单位'}
                ,{field: 'listdt', title: '开票日期'}
                ,{field: 'nums', title: '发票号码'}
                ,{field: 'piaotype_name', title: '发票类型'}
                ,{field: 'listfee', title: '不含税金额(元)',totalRow: true,align:'right',templet: function(d){return parseFormatNum(d.listfee);}}
                ,{field: 'listrate', title: '税率(%)'}
                ,{field: 'listratefee', title: '税额(元)',totalRow: true,align:'right',templet: function(d){return parseFormatNum(d.listratefee);}}
                ,{field: 'listmoney', title: '价税合计(元)',totalRow: true,align:'right',templet: function(d){return parseFormatNum(d.listmoney);}}
                ,{field: 'yongtype_name', title: '费用类别'}
                ,{field: 'caiid_name', title: '支出合同名称'}
                ,{field: 'dt', title: '收票日期'}

            ]]
            ,done : function(res, curr, count){
                $(".layui-table-tool").remove()
                soulTable.render(this);
            }
        });
        listTableSearch(form, table);


        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length < 1){
                facade.error("请选择数据");return false;
            }

            if(parent_page == '页面值'){

            }else if(parent_page == 'zhi_xiang'){
                var str = '';
                for(var key in data){
                    str += '<button type="button" style="width: auto;" class="layui-btn layui-btn-sm btn-dark" key="'+data[key].listid+'"><span class="choose_content">'+data[key].nums+'' +
                        '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                }
                $("#"+parent_dom , parent.document).append(str);

                // 样式处理
                var h = $("#"+parent_dom , parent.document).height();
                $("."+parent_dom , parent.document).css('cssText','height:'+ (h+21) +'px !important');

                parent.formValid(parent_dom);
            }else if(parent_page == 'zhi_jintui'){
                var str = '';
                var nums = $("#list_list tr", parent.document).length;
                for (var key in data){
                    if(data[key].isshen){
                        facade.error('第'+data[key].hanghao+'行数据，已存在审核中的进项退税流程,请重新选择');
                        return false;
                    }

                    nums++;
                    str += '<tr>';
                    str += '<td style="width: 45px">'+nums+'</td>';
                    str += '<td><input type="text" readonly piaoid="'+data[key].listid+'" value="'+data[key].nums+'" class="layui-input piaoid disabled"></td>';
                    str += '<td><input type="text" readonly class="layui-input disabled" value="'+data[key].gonger+'"></td>';
                    str += '<td><input type="text" readonly class="layui-input disabled" value="'+data[key].piaotype_name+'"></td>';
                    str += '<td><input type="number" readonly class="layui-input disabled" value="'+data[key].listfee+'"></td>';
                    str += '<td><input type="number" readonly class="layui-input disabled" value="'+data[key].listrate+'"></td>';
                    str += '<td><input type="number" readonly class="layui-input disabled" value="'+data[key].listratefee+'"></td>';
                    str += '<td><input type="number" readonly class="layui-input disabled" value="'+data[key].listmoney+'"></td>';
                    str += '<td><input type="number" readonly class="layui-input money disabled" value="'+data[key].listratefee+'"></td>';
                    str += '<td><input type="text" class="layui-input explain"></td>';
                    str += '</tr>';
                }
                $("#list_list", parent.document).append(str);
                if (typeof(window.parent.update_refresh_row_func)!="undefined"){
                    window.parent.update_refresh_row_func();
                }
            }else{

            }


            layer_close();
        });

    });
</script>
</body>
</html>
